package com.struts.web.user.manage.jianli;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.base.Constants;
import com.ibatis.po.user.TUserInfo;
import com.lg.system.CLGAction;
import com.struts.deal.user.register.Deal;
import com.struts.web.user.register.RegUserInfoForm;

public class JlUserInfoAction extends CLGAction {
    
	
	public ActionForward execute(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws
Exception {
		TUserInfo user = (TUserInfo)request.getSession().getAttribute("TUser");
		if(user==null){
			ActionMessages msgs = new ActionMessages();
			msgs.add("userReLogin",new ActionMessage(Constants.USER_RE_LOGIN));
			saveErrors(request, msgs);
			return actionMapping.findForward("userlogin");
		}
		RegUserInfoForm aWebForm = (RegUserInfoForm)actionForm;
		boolean result = false;
		if(aWebForm.getMethod()!="" && aWebForm.getMethod().equals("edit")){
			result=Deal.doUserInfo(aWebForm, request);
			if(result==true){
				return actionMapping.findForward("success");
			}else{
				return actionMapping.findForward("fail");
			}
		}else{
			Deal.defaultUserInfo(aWebForm, request);
			return actionMapping.getInputForward();
		}
     }
	
	
}
